home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / translate / msgclean.c < prev    next >
C/C++ Source or Header  |  1996-04-14  |  1KB  |  67 lines

  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <string.h>
  4. #include <stdarg.h>
  5. #include <ctype.h>
  6. #include "../misc/misc.h"
  7. #include "internal.h"
  8.  
  9. /*
  10.     Print an error message in a popup
  11.     Stubs to avoid linking the world
  12. */
  13. void xconf_error (const char *msg, ...)
  14. {
  15.     va_list list;
  16.     va_start (list,msg);
  17.     vfprintf (stderr,msg,list);
  18.     va_end (list);
  19. }
  20.  
  21.  
  22.  
  23. static void usage()
  24. {
  25.     fprintf (stderr,
  26.         "msgclean 1.0\n"
  27.         "msgscan dictionary_path\n"
  28.         "\n"
  29.         "Remove obsolete messages from a dictionary.\n"
  30.         "Obsolete messages can't be found in any sources anymore.\n"
  31.         "After a msgclean operation, one will generally recompile the\n"
  32.         "complete project.\n"
  33.         );
  34. }
  35.  
  36. int main (int argc, char *argv[])
  37. {
  38.     int ret = -1;
  39.     if (argc != 2){
  40.         usage();
  41.     }else{
  42.         TR_STRINGS tr;
  43.         const char *pathdict = argv[1];
  44.         tr.read (pathdict);
  45.         for (int i=0; i<tr.getnb(); i++){
  46.             TR_STRING *t = tr.getitem(i);
  47.             if (t->getnblang()==0){
  48.                 printf ("removing %s\n",t->getid());
  49.                 tr.remove_del(t);
  50.             }
  51.         }
  52.         if (tr.was_modified()){
  53.             int ver = tr.getversion();
  54.             ver++;
  55.             printf ("Updating version number of %s to %d\n",pathdict,ver);
  56.             tr.setversion(ver);
  57.             tr.write(pathdict);
  58.         }else{
  59.             printf ("%s was clean\n",pathdict);
  60.         }
  61.         ret = 0;
  62.     }
  63.     return ret;
  64. }
  65.  
  66.  
  67.